/* 
 * File:   Enemy.cpp
 * Author: Potential
 * 
 * Created on September 14, 2013, 6:19 PM
 */

#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <ctime>
#include "Enemy.h"

Enemy::Enemy() 
{
    name = "";
    curHealth = 0;
    maxHealth = 0;
    minDamage = 0;
    maxDamage = 0;
    armor = 0;
    
    criticalStrikeChance = 10;
    criticalStrikeMultiplier = 1.5;
    
    srand(static_cast<unsigned int>(time(0))); // seed random number
}

/*Enemy::Enemy(const Enemy& orig) 
{
    
}
 */

Enemy::~Enemy() 
{
    
}

void Enemy::setCurHealth(int newHealth)
{
    curHealth = newHealth;
}

void Enemy::enemySelection(int enemyNum)
{
    if (enemyNum == 1)
    {
        name = "Goblin";
        curHealth = 50;
        maxHealth = 50;
        minDamage = 5;
        maxDamage = 8;
        armor = 3;
    }
    else if (enemyNum == 2)
    {
        name = "Ghoul";
        curHealth = 80;
        maxHealth = 80;
        minDamage = 8;
        maxDamage = 15;
        armor = 5;
    }
    else if (enemyNum == 3)
    {
        name = "Zombie";
        curHealth = 100;
        maxHealth = 100;
        minDamage = 10;
        maxDamage = 20;
        armor = 5;
    }
    //Should never go here, but just in case
    else
    {
        curHealth = 0;
        maxHealth = 0;
        minDamage = 0;
        maxDamage = 0;
        armor = 0;
    }
}

int Enemy::getDamage() {
    int damage = 0;
    //randomNumber = rand() % 20 + 1;
    damage = (rand() % (maxDamage - minDamage)) + minDamage;

    if (isCriticalStrike() == true) {
        damage = damage * getCriticalStrikeMultiplier();
    }

    return damage;
}

void Enemy::displayStats()
{
    cout << "===========================" << endl;
    cout << "Enemy: " << name << endl;
    cout << "Health: " << curHealth << " / " << maxHealth << endl;
    cout << "Damage: " << minDamage << " - " << maxDamage << endl;
    cout << "Armor: " << armor << endl;
    cout << "===========================" << endl << endl;    
}

void Enemy::setCriticalStrikeMultiplier(double criticalStrikeMultiplier) {
    this->criticalStrikeMultiplier = criticalStrikeMultiplier;
}

double Enemy::getCriticalStrikeMultiplier() const {
    return criticalStrikeMultiplier;
}

void Enemy::setCriticalStrikeChance(int criticalStrikeChance) {
    this->criticalStrikeChance = criticalStrikeChance;
}

int Enemy::getCriticalStrikeChance() const {
    return criticalStrikeChance;
}

void Enemy::setCriticalStrike() {
    int critSeed = rand() % 100 + 1;

    if (getCriticalStrikeChance() >= critSeed) {
        criticalStrike = true;
    } else {
        criticalStrike = false;
    }
}

bool Enemy::isCriticalStrike() const {
    return criticalStrike;
}